import * as types from '../mutation-types';
import { doAjax } from 'utils';

const state = {
  app:{
    name: '',
    menu: [],
    userInfo: {
      account: '',
      nickName: ''
    }
  }
}

// getters
const getters = {
  
}

// actions
const actions = {
  // rootState根节点的状态
  'initApp' ({ state, commit, rootState }, data) {
    return doAjax({
      url: URLConfig('baseInfo'),
      sucCallback(data) {
        commit('INIT_APP', data);
      }
    })
  }
}

// mutations
const mutations = {
  INIT_APP(state, data) {
    state.app = data;
  }
}

export default {
  namespaced: true,
  state,
  getters,
  actions,
  mutations
}